#{{ ansible_managed}}
{% macro _oslomsg_url(transport, userid, password, hosts, port, vhost, query='') %}
{% set _url = [] %}
{% for host in hosts %}
{%   set _ = _url.append(userid + ':' + password + '@' + hostvars[host]['ansible_host'] + ':' + port) %}
{% endfor %}
{{ transport }}://{{ _url | join(',') }}/{{ vhost }}?{{ query }}
{% endmacro %}

[DEFAULT]
use_journal = True
# Disable stderr logging
use_stderr = False
debug = {{ debug }}
auth_strategy = keystone
aodh_is_enabled = {{ ceilometer_aodh_enabled | bool }}

# RPC
transport_url = {{ _oslomsg_url(ceilometer_oslomsg_rpc_transport, ceilometer_oslomsg_rpc_userid, ceilometer_oslomsg_rpc_password, groups[ceilometer_oslomsg_rpc_host_group], ceilometer_oslomsg_rpc_port, ceilometer_oslomsg_rpc_vhost, query=(ceilometer_oslomsg_rpc_use_ssl | bool | ternary('ssl=1', ''))) }}

{% if ceilometer_gnocchi_enabled | bool %}
event_dispatchers = gnocchi
meter_dispatchers = gnocchi
{% else %}
meter_dispatchers = database
event_dispatchers = database
{% endif %}

{% if 'ceilometer_agent_central' in group_names %}
polling_namespaces = central
{% elif 'ceilometer_agent_compute' in group_names %}
polling_namespaces = compute
{% endif %}

[oslo_messaging_rabbit]
ssl = {{ ceilometer_oslomsg_rpc_use_ssl }}

[api]
gnocchi_is_enabled = {{ ceilometer_gnocchi_enabled | bool }}

{% if 'ceilometer_agent_notification' in group_names %}
[notification]
workers = {{ ceilometer_notification_workers }}
store_events = {{ not ceilometer_gnocchi_enabled | bool }}

# Notification queues to listen on

# Ceilometer needs to connect to it's own notification vhost
messaging_urls = {{ _oslomsg_url(ceilometer_oslomsg_notify_transport, ceilometer_oslomsg_notify_userid, ceilometer_oslomsg_notify_password, groups[ceilometer_oslomsg_notify_host_group], ceilometer_oslomsg_notify_port, ceilometer_oslomsg_notify_vhost, query=(ceilometer_oslomsg_notify_use_ssl | bool | ternary('ssl=1', ''))) }}

{% if cinder_ceilometer_enabled %}
# Cinder notifications
messaging_urls = {{ _oslomsg_url(cinder_oslomsg_notify_transport, cinder_oslomsg_notify_userid, cinder_oslomsg_notify_password, groups[cinder_oslomsg_notify_host_group], cinder_oslomsg_notify_port, cinder_oslomsg_notify_vhost, query=(cinder_oslomsg_notify_use_ssl | bool | ternary('ssl=1', ''))) }}
{% endif %}

{% if designate_ceilometer_enabled %}
# Designate notifications
messaging_urls = {{ _oslomsg_url(designate_oslomsg_notify_transport, designate_oslomsg_notify_userid, designate_oslomsg_notify_password, groups[designate_oslomsg_notify_host_group], designate_oslomsg_notify_port, designate_oslomsg_notify_vhost, query=(designate_oslomsg_notify_use_ssl | bool | ternary('ssl=1', ''))) }}
{% endif %}

{% if glance_ceilometer_enabled %}
# Glance notifications
messaging_urls = {{ _oslomsg_url(glance_oslomsg_notify_transport, glance_oslomsg_notify_userid, glance_oslomsg_notify_password, groups[glance_oslomsg_notify_host_group], glance_oslomsg_notify_port, glance_oslomsg_notify_vhost, query=(glance_oslomsg_notify_use_ssl | bool | ternary('ssl=1', ''))) }}
{% endif %}

{% if heat_ceilometer_enabled %}
# Heat notifications
messaging_urls = {{ _oslomsg_url(heat_oslomsg_notify_transport, heat_oslomsg_notify_userid, heat_oslomsg_notify_password, groups[heat_oslomsg_notify_host_group], heat_oslomsg_notify_port, heat_oslomsg_notify_vhost, query=(heat_oslomsg_notify_use_ssl | bool | ternary('ssl=1', ''))) }}
{% endif %}

{% if keystone_ceilometer_enabled %}
# Keystone notifications
messaging_urls = {{ _oslomsg_url(keystone_oslomsg_notify_transport, keystone_oslomsg_notify_userid, keystone_oslomsg_notify_password, groups[keystone_oslomsg_notify_host_group], keystone_oslomsg_notify_port, keystone_oslomsg_notify_vhost, query=(keystone_oslomsg_notify_use_ssl | bool | ternary('ssl=1', ''))) }}
{% endif %}

{% if neutron_ceilometer_enabled %}
# Neutron notifications
messaging_urls = {{ _oslomsg_url(neutron_oslomsg_notify_transport, neutron_oslomsg_notify_userid, neutron_oslomsg_notify_password, groups[neutron_oslomsg_notify_host_group], neutron_oslomsg_notify_port, neutron_oslomsg_notify_vhost, query=(neutron_oslomsg_notify_use_ssl | bool | ternary('ssl=1', ''))) }}
{% endif %}

{% if nova_ceilometer_enabled %}
# Nova notifications
messaging_urls = {{ _oslomsg_url(nova_oslomsg_notify_transport, nova_oslomsg_notify_userid, nova_oslomsg_notify_password, groups[nova_oslomsg_notify_host_group], nova_oslomsg_notify_port, nova_oslomsg_notify_vhost, query=(nova_oslomsg_notify_use_ssl | bool | ternary('ssl=1', ''))) }}
{% endif %}

{% if sahara_ceilometer_enabled %}
# Sahara notifications
messaging_urls = {{ _oslomsg_url(sahara_oslomsg_notify_transport, sahara_oslomsg_notify_userid, sahara_oslomsg_notify_password, groups[sahara_oslomsg_notify_host_group], sahara_oslomsg_notify_port, sahara_oslomsg_notify_vhost, query=(sahara_oslomsg_notify_use_ssl | bool | ternary('ssl=1', ''))) }}
{% endif %}

{% if swift_ceilometer_enabled %}
# Ceilometer notifications
messaging_urls = {{ _oslomsg_url(swift_oslomsg_notify_transport, swift_oslomsg_notify_userid, swift_oslomsg_notify_password, groups[swift_oslomsg_notify_host_group], swift_oslomsg_notify_port, swift_oslomsg_notify_vhost, query=(swift_oslomsg_notify_use_ssl | bool | ternary('ssl=1', ''))) }}
{% endif %}

{% if trove_ceilometer_enabled %}
# Trove notifications
messaging_urls = {{ _oslomsg_url(trove_oslomsg_notify_transport, trove_oslomsg_notify_userid, trove_oslomsg_notify_password, groups[trove_oslomsg_notify_host_group], trove_oslomsg_notify_port, trove_oslomsg_notify_vhost, query=(trove_oslomsg_notify_use_ssl | bool | ternary('ssl=1', ''))) }}
{% endif %}
{% endif %}

{% if ceilometer_gnocchi_enabled | bool %}
[dispatcher_gnocchi]
archive_policy = low
{% if gnocchi_storage_driver is defined and gnocchi_storage_driver == 'swift' %}
filter_service_activity = True
filter_project = {{ gnocchi_service_project_name }}
{% endif %}

[storage]
max_retries = 80
{% endif %}

[publisher]
telemetry_secret = {{ ceilometer_telemetry_secret }}

[service_credentials]
insecure = {{ keystone_service_internaluri_insecure | bool }}
auth_url = {{ keystone_service_adminurl }}
auth_type = {{ ceilometer_keystone_auth_plugin }}
project_domain_id = {{ ceilometer_service_project_domain_id }}
user_domain_id = {{ ceilometer_service_user_domain_id }}
project_name = {{ ceilometer_service_project_name }}
username = {{ ceilometer_service_user_name }}
password = {{ ceilometer_service_password }}
region_name = {{ ceilometer_service_region }}
interface = {{ ceilometer_service_interface }}
